home *** CD-ROM | disk | FTP | other *** search
/ Introduction to 3D Game …ogramming with DirectX 12 / Introduction-to-3D-Game-Programming-with-DirectX-12.ISO / Code.Textures / Chapter 18 Cube Mapping / DynamicCube / CubeRenderTarget.h < prev    next >
Encoding:
C/C++ Source or Header  |  2016-03-02  |  1.6 KB  |  66 lines

  1. //***************************************************************************************
  2. // CubeRenderTarget.h by Frank Luna (C) 2015 All Rights Reserved.
  3. //***************************************************************************************
  4.  
  5. #pragma once
  6.  
  7. #include "../../Common/d3dUtil.h"
  8.  
  9. enum class CubeMapFace : int
  10. {
  11.     PositiveX = 0,
  12.     NegativeX = 1,
  13.     PositiveY = 2,
  14.     NegativeY = 3,
  15.     PositiveZ = 4,
  16.     NegativeZ = 5
  17. };
  18.  
  19. class CubeRenderTarget
  20. {
  21. public:
  22.     CubeRenderTarget(ID3D12Device* device,
  23.         UINT width, UINT height,
  24.         DXGI_FORMAT format);
  25.         
  26.     CubeRenderTarget(const CubeRenderTarget& rhs)=delete;
  27.     CubeRenderTarget& operator=(const CubeRenderTarget& rhs)=delete;
  28.     ~CubeRenderTarget()=default;
  29.  
  30.     ID3D12Resource* Resource();
  31.     CD3DX12_GPU_DESCRIPTOR_HANDLE Srv();
  32.     CD3DX12_CPU_DESCRIPTOR_HANDLE Rtv(int faceIndex);
  33.  
  34.     D3D12_VIEWPORT Viewport()const;
  35.     D3D12_RECT ScissorRect()const;
  36.  
  37.     void BuildDescriptors(
  38.         CD3DX12_CPU_DESCRIPTOR_HANDLE hCpuSrv,
  39.         CD3DX12_GPU_DESCRIPTOR_HANDLE hGpuSrv,
  40.         CD3DX12_CPU_DESCRIPTOR_HANDLE hCpuRtv[6]);
  41.  
  42.     void OnResize(UINT newWidth, UINT newHeight);
  43.  
  44. private:
  45.     void BuildDescriptors();
  46.     void BuildResource();
  47.  
  48. private:
  49.  
  50.     ID3D12Device* md3dDevice = nullptr;
  51.  
  52.     D3D12_VIEWPORT mViewport;
  53.     D3D12_RECT mScissorRect;
  54.  
  55.     UINT mWidth = 0;
  56.     UINT mHeight = 0;
  57.     DXGI_FORMAT mFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
  58.  
  59.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuSrv;
  60.     CD3DX12_GPU_DESCRIPTOR_HANDLE mhGpuSrv;
  61.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuRtv[6];
  62.  
  63.     Microsoft::WRL::ComPtr<ID3D12Resource> mCubeMap = nullptr;
  64. };
  65.  
  66.